<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="/libs/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<?php
$servername = "mysql";
$username = "root";
$password = "password";
$dbname = "test";

// 创建连接
$conn = new mysqli($servername, $username, $password, $dbname);
// 检测连接
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
}

$sql = "SELECT id, name, description, type FROM plan";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    echo "<table class='table table-bordered table-striped table-hover'>";
    echo "<thead><tr style='text-align: center;'><td>计划</td><td>描述</td><td>删除计划</td><td>类型</td></tr></thead>";
    // 输出每行数据
    while($row = $result->fetch_assoc()) {
        $id = $row["id"];
        $name = $row["name"];
        $description = $row["description"];
        $type = $row["type"];
        echo "<tr>";
        echo "<td><a href='/plan/plan_form.php?id=$id'>$name</a></td><td>$description</td>";
        echo "<td><a href='/plan/plan_manager.php?id=$id&delete=true'>删除</a></td><td>$type</td>";
        echo "</tr>";


    }
    echo "</table>";
} else {
    echo "0 个结果";
}
$conn->close();
?>
<ul>
    <li><a href="/plan/plan_form.php">新增计划</a></li>
    <li><a href="/plan/plan_list.php">计划列表</a></li>
</ul>
</body>
</html>
